<?php
namespace Home\Model;
use Think\Model;

/**
 * 用户模型
 * @author Bean
 *
 */
class UserModel extends Model {
	
	//自动完成
	protected $_auto = array(
		array('password', 'sha1', self::MODEL_BOTH, 'function'),
		array('create_time', 'time', self::MODEL_INSERT, 'function')
	);
	
	//注册一个用户
	public function reg($username, $password, $email) {
		$data = array(
			'username' => $username,
			'password' => $password,
			'email'    => $email
		);
		
		if($this->create($data)) {
			$uid = $this->add();
			return $uid ? $uid : 0;
		}
	}
	
}

?>